﻿using System;
using System.Collections.Generic;
using MugenInjection.Delegates;
using MugenInjection.Infrastructure;

namespace MugenInjection.Interface
{
    /// <summary>
    /// Represents the interface that contains information about a service registration.
    /// </summary>
    public interface IBinding : IDisposableObject
    {
        /// <summary>
        /// Gets the actions that should be called before instances are activated via the binding.
        /// </summary>
        ICollection<Action<IBindingContext>> ActivatingActions { get; }

        /// <summary>
        /// Gets the actions that should be called after instances are activated via the binding.
        /// </summary>
        ICollection<BindingActivatedDelegate<object>> ActivatedActions { get; }

        /// <summary>
        /// Gets the actions that should be called before binding are deactivated.
        /// </summary>
        ICollection<Action<IBinding>> DeactivatedActions { get; }

        /// <summary>
        /// Gets the lifecycle scope.
        /// </summary>
        IScopeLifecycle ScopeLifecycle { get; }

        /// <summary>
        /// Gets the priority.
        /// </summary>
        BindingPriority Priority { get; }

        /// <summary>
        /// Gets the parameters.
        /// </summary>
        IList<IInjectionParameter> Parameters { get; }

        /// <summary>
        /// Gets the service types.
        /// </summary>
        IList<Type> Services { get; }

        /// <summary>
        /// Gets the settings.
        /// </summary>
        ISettings Settings { get; }

        /// <summary>
        /// Determines whether the specified request can be resolved.
        /// </summary>
        /// <param name="bindingContext">The specified <see cref="IBindingContext"/>.</param>
        /// <returns><c>True</c> if the specified service has been resolved; otherwise, <c>false</c>.</returns>
        bool CanResolve(IBindingContext bindingContext);

        /// <summary>
        /// Resolves instance for the specified <see cref="IBindingContext"/>.
        /// </summary>
        /// <param name="bindingContext">The specified <see cref="IBindingContext"/>.</param>
        /// <returns>An instance of the service.</returns>
        object Resolve(IBindingContext bindingContext);
    }
}